package org.zy;


import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * @Description:
 * @Author: zara
 * @Version V3.0
 * @Date: 2022/3/22 5:54 下午
 */

public class RiskAnalysisRule {
    private static Map<String, String> value;

    public static Map<String, String> get() {
        value = new HashMap<>();

        add(MetricConstants.CPU_AVG_PCT, "x < 0.6,LOW;0.6 <= x < 0.7,MEDIUM;x >= 0.7,HIGH_CPU高负荷;");
        add(MetricConstants.MEMORY_USED_PCT, "x < 0.8,LOW;0.8 <= x < 0.95,MEDIUM;x >= 0.95,HIGH_内存高负荷;");
        add(MetricConstants.FILESYSTEM_USED_PCT, "x < 0.6,LOW;0.6 <= x < 0.95,MEDIUM;x >= 0.95,HIGH_磁盘容量不足;");
        add(MetricConstants.DISK_READ_BYTES_PERSECOND, "x < 1k,LOW;1k <= x < 1m,MEDIUM;x >= 1m,HIGH_磁盘读高负荷;");
        add(MetricConstants.DISK_WRITE_BYTES_PERSECOND, "x < 1k,LOW;1k <= x < 1m,MEDIUM;x >= 1m,HIGH_磁盘写高负荷;");
        add("runtime", "x < 31536000000,LOW;31536000000 <= x < 94608000000,MEDIUM;x >= 3*365*24*60*60*1000,HIGH_长期运行;");//大于3年高风险
        //by zara 网络无法一次性计算上传下载速率，高风险分析需借助network表
        add(MetricConstants.NETWORK_IN_BYTES_PERSECOND, "x < 100k,LOW;100k <= x < 1m,MEDIUM;x >= 1m,HIGH_网络下载高负荷;");//传入数据为Byte，下同
        add(MetricConstants.NETWORK_OUT_BYTES_PERSECOND, "x < 100k,LOW;100k <= x < 1m,MEDIUM;x >= 1m,HIGH_网络上传高负荷;");
        return value;
    }

    private static void add(String key, String rule) {
        value.put(key, rule);
    }

    public Set<String> keySet() {
        return value.keySet();
    }

}

